package com.angel.architecture.event.listener;


import java.util.ArrayList;
import java.util.List;

import com.angel.architecture.event.base.ApplicationEvent;

/**
 * <p>Un objeto de clase <tt>CompositeApplicartionEventListener</tt> representa una listener de eventos
 * compuestos por otros listeners</p>
 *
 * @author Juan Isern
 * @see ApplicationEventListener
 */
public class CompositeApplicationEventListener<E extends ApplicationEvent> implements ApplicationEventListener<E> {

	private List<ApplicationEventListener<?>> listeners = new ArrayList<ApplicationEventListener<?>>();

    public void setListeners(List<ApplicationEventListener<?>> listeners) {
        this.listeners = listeners;
    }

    @SuppressWarnings("unchecked")
    public void onEvent(E event) {
        for (ApplicationEventListener listener : listeners) {
            listener.onEvent(event);
        }
    }
}
